package com.k12.edu.service.impl;



import com.k12.edu.dao.SchoolClassInfoDao;
import com.k12.edu.entity.SchoolClassInfo;
import com.k12.edu.service.SchoolClassInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 学校年级班级信息表(SchoolClassInfo)表服务实现类
 *
 * @author makejava
 * @since 2025-08-01 11:20:14
 */
@Service("schoolClassInfoService")
public class SchoolClassInfoServiceImpl implements SchoolClassInfoService {
    @Resource
    private SchoolClassInfoDao schoolClassInfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SchoolClassInfo queryById(Integer id) {
        return this.schoolClassInfoDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param schoolClassInfo 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public List<SchoolClassInfo> queryByPage(SchoolClassInfo schoolClassInfo) {
        long total = this.schoolClassInfoDao.count(schoolClassInfo);
        return this.schoolClassInfoDao.queryAllByLimit(schoolClassInfo);
    }

    /**
     * 新增数据
     *
     * @param schoolClassInfo 实例对象
     * @return 实例对象
     */
    @Override
    public SchoolClassInfo insert(SchoolClassInfo schoolClassInfo) {
        this.schoolClassInfoDao.insert(schoolClassInfo);
        return schoolClassInfo;
    }

    /**
     * 修改数据
     *
     * @param schoolClassInfo 实例对象
     * @return 实例对象
     */
    @Override
    public SchoolClassInfo update(SchoolClassInfo schoolClassInfo) {
        this.schoolClassInfoDao.update(schoolClassInfo);
        return this.queryById(schoolClassInfo.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.schoolClassInfoDao.deleteById(id) > 0;
    }
}
